﻿using System;

namespace MobySharp
{
    [AttributeUsage(AttributeTargets.Property)]
    internal class PostDataInstruction : Attribute
    {
        private string fieldname;
        private int? maxLength;
        private bool required;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldname"></param>
        public PostDataInstruction(string fieldname)
        {
            this.fieldname = fieldname;
            required = false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldname"></param>
        /// <param name="required">defaults to false</param>
        public PostDataInstruction(string fieldname, bool required)
        {
            this.fieldname = fieldname;
            this.required = required;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldname"></param>
        /// <param name="required">defaults to false</param>
        /// <param name="maxLength"></param>
        public PostDataInstruction(string fieldname, bool required, int maxLength)
        {
            this.fieldname = fieldname;
            this.required = required;
            this.maxLength = maxLength;
        }

        public string Fieldname
        {
            get { return fieldname; }
        }

        public bool Required
        {
            get { return required; }
        }

        public int? MaxLength
        {
            get { return maxLength; }
        }
    }
}